1. Field of the Invention
The present invention relates to a compiler for converting a source program written in a compiler language, which is sometimes referred to as a high-level programming language, for example C language, C++ language, Java® language, classical compiler languages such as FORTRAN and COBOL, or APL, PL/1, ADA, Smalltalk, Lisp, an assembler language, or any other type of programming language, into an object program in an intermediate language which serves as a process for converting the source program into a machine language, for example a machine language that can be executed directly by a CPU (Central Processing Unit) (note that CPU includes an MPU (Micro Processing Unit)). The present invention also relates to a program product based on this compiler, a compilation device for performing compilation, a communication terminal device comprising the compilation device, and a compilation method for performing compilation. Note that the aforementioned “Java®” is a registered trademark of the U.S. company Sun Microsystems. In this specification, the symbol ® indicates a registered trademark.
2. Description of the Related Art
The device disclosed in Japanese Unexamined Patent Publication H6-202875, for example, is known as a conventional partial compiler. The objects of the conventional partial compiler disclosed in Japanese Unexamined Patent Publication H6-202875 are to enable determination of the necessity of in-line expansion for each function call, to perform in-line expansion corresponding to an execution image, and to enable practical and efficient in-line expansion. In this prior art, to achieve these objects, control flow weighting means estimates the number of times each partial control flow constituting a control flow has been executed on the basis of an analysis result of control flow analyzing means, and weights each partial control flow based on the number of executions. Further, object generating means determines the necessity of in-line expansion for a function called by each function call with reference to the result of the weighting performed by the control flow weighting means, and generate an object program reflecting this determination.
When calculating the number of executions to determine the compilation part, and when a subprogram executed within the program that is called from another program has a so-called multi-nested loop structure, the conventional partial compiler described in Japanese Unexamined Patent Publication H6-202875 calculates the number of executions in consideration of the degree of multi-nesting in the loop, or in other words the loop depth. In the case of a subprogram that is executed by a caller program and also has a multi-nested loop structure, however, this partial compiler does not consider the degree of multi-nesting in the loop within the read source program.
Hence the conventional partial compiler described in Japanese Unexamined Patent Publication H6-202875 is problematic in that it considers the depth of the loop executed at the call source and the depth of the loop executed at the call destination together, and is therefore unable to compile parts having a large total number of executions preferentially. As a result, this prior art is unable to optimize improvements in the program execution speed and economizing on the storage capacity of the memory that is used to store the programs.
Another problem in the prior art described in Japanese Unexamined Patent Publication H6-202875 is that in a case where a loop with a double-nested structure exists, for example, when the return destination of each loop has the same address and different labels (in other words, a symbol indicating the address) are not attached, a judgment cannot be made as to whether a return destination is a return from a point on a single loop and a final return, or a return destination of a loop having a double-nested structure. Hence the prior art is unable to calculate the loop depth or number of executions accurately. In other words, here too the prior art is unable to extract parts with a large number of executions accurately and compile these parts preferentially, and hence improvements in execution speed and economizing on the memory regions to be used cannot be optimized.